import Vue from 'vue'
import axios from '@/libs/api.request'
import Url from '@/tool/Url'
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'

Vue.use(Viewer)
Viewer.setDefaults({
    navbar: false, //底部缩略图
    toolbar: false, //底部工具栏
    button: false, //右上角按钮
    title: false, //当前图片标题
    movable: true, //是否可以移动
    zoomable: true, //是否可以缩放
    transition: false //使用 CSS3 过度
})

export const getQiniu = () => {
    return axios.request({
        url: 'qiniu/get-token',
        method: 'post'
    })
}

export const fetchImg = data => {
    return axios.request({
        url: 'img/fetch-img',
        method: 'post',
        data
    })
}

// 区域列表
export const areaList = data => {
    return axios.request({
        url: 'backend/area/three-city-list',
        method: 'post',
        data
    })
}

// 门店列表
export const shopList = data => {
    return axios.request({
        url: 'backend/shop/list',
        method: 'post',
        data
    })
}

// 添加/编辑门店
export const editShop = data => {
    return axios.request({
        url: '/backend/shop/edit',
        method: 'post',
        data
    })
}

// 修改门店状态
export const changeShopStatus = data => {
    return axios.request({
        url: '/backend/shop/change-status',
        method: 'post',
        data
    })
}

// 门店select数据源
export const shopForSelect = data => {
    return axios.request({
        url: '/backend/shop/list-for-select',
        method: 'post',
        data
    })
}

// 角色列表
export const roleList = data => {
    return axios.request({
        url: '/backend/role/role-list',
        method: 'post',
        data
    })
}

// 创建角色
export const createRole = data => {
    return axios.request({
        url: '/backend/role/create-role',
        method: 'post',
        data
    })
}

// 更新角色
export const updateRole = data => {
    return axios.request({
        url: '/backend/role/update-role',
        method: 'post',
        data
    })
}

// 删除角色
export const deleteRole = data => {
    return axios.request({
        url: '/backend/role/delete-role',
        method: 'post',
        data
    })
}

// 角色详情
export const getRoleInfo = data => {
    return axios.request({
        url: '/backend/role/role-info',
        method: 'post',
        data
    })
}

// 创建角色选择权限列表
export const getAuthList = data => {
    return axios.request({
        url: 'backend/permission/tree-data',
        method: 'post',
        data
    })
}

// 权限列表
export const authList = data => {
    let url = Url.getPath('/backend/permission/auth-list', data)
    return axios.request({
        url: url,
        method: 'get',
    })
}

// 页面按钮权限列表
export const pageBtnPermission = data => {
    return axios.request({
        url: '/backend/permission/page-btn-permission',
        method: 'post',
        data
    })
}

// 用户已分配的按钮权限列表
export const childBtnPermission = data => {
    return axios.request({
        url: '/backend/permission/child-btn-permission',
        method: 'post',
        data
    })
}

// 权限角色
export const createAuth = data => {
    return axios.request({
        url: '/backend/permission/create-auth',
        method: 'post',
        data
    })
}

// 删除权限
export const deleteAuth = data => {
    return axios.request({
        url: '/backend/permission/delete-auth',
        method: 'post',
        data
    })
}

// 根据角色获取权限
export const getRoleAuth = data => {
    return axios.request({
        url: '/backend/permission/get-role-auth',
        method: 'post',
        data
    })
}

//管理员列表
export const getUserList = data => {
    return axios.request({
        url: '/backend/user/manager-list',
        method: 'post',
        data
    })
}

export const adminListForSelect = data => {
    return axios.request({
        url: '/backend/user/admin-list-for-select',
        method: 'post',
        data
    })
}

//管理员列表
export const changeUserStatus = data => {
    return axios.request({
        url: '/backend/user/change-user-status',
        method: 'post',
        data
    })
}

//添加编辑管理员
export const editeUser = data => {
    return axios.request({
        url: 'backend/user/edit-user',
        method: 'post',
        data
    })
}

/**
 * 轮播图列表
 * @param data
 */
export const bannerList = data => {
    return axios.request({
        url: 'backend/banner/list',
        method: 'post',
        data
    })
}

/**
 * 添加/编辑轮播图
 * @param data
 */
export const editBanner = data => {
    return axios.request({
        url: 'backend/banner/edit',
        method: 'post',
        data
    })
}

/**
 * 修改轮播图状态
 * @param data
 */
export const changeBannerStatus = data => {
    return axios.request({
        url: 'backend/banner/change-status',
        method: 'post',
        data
    })
}

/**
 * 商品分类列表
 * @param data
 */
export const goodsCategoryList = data => {
    return axios.request({
        url: 'backend/good-cate/list',
        method: 'post',
        data
    })
}

/**
 * 添加/编辑商品分类
 * @param data
 */
export const editGoodsCategory = data => {
    return axios.request({
        url: 'backend/good-cate/edit',
        method: 'post',
        data
    })
}

/**
 * 修改商品分类状态
 * @param data
 */
export const changeGoodsCategoryStatus = data => {
    return axios.request({
        url: 'backend/good-cate/change-status',
        method: 'post',
        data
    })
}

/**
 * 一级商品分类select数据源
 * @param data
 */
export const parentListOfGoodsCategoryForSelect = data => {
    return axios.request({
        url: 'backend/good-cate/parent-list-for-select',
        method: 'post',
        data
    })
}

/**
 * 所有商品分类Cascader数据源
 * @param data
 */
export const allGoodsCategoryList = data => {
    return axios.request({
        url: 'backend/good-cate/all-list',
        method: 'post',
        data
    })
}

/**
 * 商品列表
 * @param data
 */
export const goodsList = data => {
    return axios.request({
        url: 'backend/good/list',
        method: 'post',
        data
    })
}

/**
 * 商品添加/编辑
 * @param data
 */
export const editGoods = data => {
    return axios.request({
        url: 'backend/good/edit',
        method: 'post',
        data
    })
}

/**
 * 修改商品状态
 * @param data
 */
export const changeGoodsStatus = data => {
    return axios.request({
        url: 'backend/good/change-status',
        method: 'post',
        data
    })
}

/**
 * 商品select数据源
 * @param data
 */
export const goodsListForSelect = data => {
    return axios.request({
        url: 'backend/good/list-for-select',
        method: 'post',
        data
    })
}

/**
 * 客户列表
 * @param data
 */
export const customerList = data => {
    return axios.request({
        url: 'backend/customer/list',
        method: 'post',
        data
    })
}

/**
 * 客户select数据源
 * @param data
 */
export const customerListForSelect = data => {
    return axios.request({
        url: 'backend/customer/list-for-select',
        method: 'post',
        data
    })
}

/**
 * 收藏列表
 * @param data
 */
export const customerCollectList = data => {
    return axios.request({
        url: 'backend/customer/collect-list',
        method: 'post',
        data
    })
}

/**
 * 客户预约列表
 * @param data
 */
export const customerAppointmentList = data => {
    return axios.request({
        url: 'backend/appointment/appointment-list',
        method: 'post',
        data
    })
}

/**
 * 客户预约信息状态变更
 * @param data
 */
export const changeAppointmentServiceState = data => {
    return axios.request({
        url: 'backend/appointment/change-service-state',
        method: 'post',
        data
    })
}

/**
 * 订单列表
 * @param data
 */
export const orderList = data => {
    return axios.request({
        url: 'backend/order/order-list',
        method: 'post',
        data
    })
}

/**
 * 订单详情
 * @param data
 */
export const orderInfo = id => {
    return axios.request({
        url: 'backend/order/order-detail',
        method: 'post',
        data: {
            id
        }
    })
}

/**
 * 退款列表
 * @param data
 */
export const refundList = data => {
    return axios.request({
        url: 'backend/order/refund-list',
        method: 'post',
        data
    })
}

/**
 * 退款审核
 * @param data
 */
export const auditOrderRefund = data => {
    return axios.request({
        url: 'backend/order/audit-order-refund',
        method: 'post',
        data
    })
}

/**
 * 订单服务状态变更
 * @param data
 */
export const changeOrderServiceState = data => {
    return axios.request({
        url: 'backend/order/change-order-service-state',
        method: 'post',
        data
    })
}

/**
 * 平台/门店订单统计
 * @param data
 */
export const orderStatistics = data => {
    return axios.request({
        url: 'backend/finance/order-statistics',
        method: 'post',
        data
    })
}

/**
 * 平台/门店账单明细
 * @param data
 */
export const orderRecordList = data => {
    return axios.request({
        url: 'backend/finance/order-record',
        method: 'post',
        data
    })
}

/**
 * 门店最新提现的信息
 * @param data
 */
export const latestCashInfo = data => {
    return axios.request({
        url: 'backend/finance/new-cash-info',
        method: 'post',
        data
    })
}

/**
 * 门店发起提现
 * @param data
 */
export const addCash = data => {
    return axios.request({
        url: 'backend/finance/add-cash',
        method: 'post',
        data
    })
}

/**
 * 门店提现记录
 * @param data
 * @returns {*}
 */
export const cashList = data => {
    return axios.request({
        url: 'backend/finance/cash-list',
        method: 'post',
        data
    })
}

/**
 * 门店提现审核
 * @param data
 * @returns {*}
 */
export const auditCash = data => {
    return axios.request({
        url: 'backend/finance/audit-cash',
        method: 'post',
        data
    })
}

/**
 * 编辑场景省市区Cascader
 */
export const cityListForEdit = () => {
    return axios.request({
        url: 'backend/area/three-city-list',
        method: 'get'
    })
}

/**
 * 查询场景省市区Cascader
 */
export const cityList = () => {
    return axios.request({
        url: 'backend/area/three-city-list-for-shop',
        method: 'get'
    })
}

/**
 * 获取结算函
 */
export const getJsTemp = data => {
    return axios.request({
        url: 'backend/finance/get-js-temp',
        method: 'post',
        data
    })
}









